<?php

namespace app\admin\controller\paotui;

use app\common\controller\Backend;

/**
 * 基础价格管理
 *
 * @icon fa fa-circle-o
 */
class Generalprice extends Backend
{
    
    /**
     * Distanceprice模型对象
     * @var \app\admin\model\paotui\Generalprice
     */
    protected $model = null;

    public function _initialize()
    {
        parent::_initialize();
        $this->model = new \app\admin\model\paotui\Generalprice;

    }

    public function index()
    {
        if($this->request->isPost()){
            $params = $this->request->post("row/a");

            foreach ($params as $k=>$v){
                $model = new \app\admin\model\paotui\Generalprice();
                $price = $model->where(['id'=>$k])->find();

                if($price){
                    $price->save(['price'=>$v['price']]);
                }

            }
            $this->success("请求成功");

        }
        $model = new \app\admin\model\paotui\Generalprice();
        $generalList = collection($model->order("type asc")->select())->toArray();

        $this->assign('generalList',$generalList);

        return $this->fetch();
    }
}
